/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.reg;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: jse2302 - Ab
 * <p>Powered by webrx On 2023-06-21 09:02:06
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ab {
    public static void main(String[] args) throws IOException {
       Scanner sc = new Scanner(System.in);
        System.out.println("请输入电话");
        String phone = sc.next();
        String p = "^1\\d{10}$";
        String num = "";
        if(phone.matches(p)){
            String u = "https://ip138.com/mobile.asp?mobile="+phone+"&action=mobile";
            String doc = Jsoup.connect(u).get().toString();
            Pattern pa = Pattern.compile("<td><span>(.+)</span></td>");
            Matcher matcher = pa.matcher(doc);
            while(matcher.find()){
                System.out.println(matcher.group(1));
            }
          }else{
            System.out.println("手机号格式不正确");
        }


    }
}
